package com.zxtech.zzm.zxmonitorsocket.resolver

import com.zxtech.zzm.core.util.LoggerUtil.Companion.LOGGERUTIL_ERROR
import com.zxtech.zzm.zxmonitorsocket.SocketPackage
import com.zxtech.zzm.zxmonitorsocket.ZXMonitorSocketService
import com.zxtech.zzm.zxmonitorsocket.thread.ThreadPoolManager
import com.zxtech.zzm.zxmonitorsocket.util.SocketLoggerUtil

class RegisterResolver : SocketBaseResolver() {
  override fun resolve(content: Any) {
    val socketPackage: SocketPackage = content as SocketPackage
    if ("01" == socketPackage.packageContent) {//注册成功
      SocketLoggerUtil.logSocket("注册成功")
      ThreadPoolManager.instance?.execute(ZXMonitorSocketService.getHeartBeatThread())
    } else {
      SocketLoggerUtil.logSocket("注册失败", LOGGERUTIL_ERROR)
    }
  }

  companion object {
    private val ourInstance = RegisterResolver()

    fun handlePackage(socketPackage: SocketPackage?) {
      ourInstance.resolve(socketPackage!!)
    }
  }
}